<!DOCTYPE html>
<html>

<head>
  <title></title>
  <meta charset="utf-8">
  <!-- 最新 Bootstrap 核心 CSS 文件 -->
  <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap.min.css">

  <!-- 可选的Bootstrap主题文件（一般不用引入） -->
  <link rel="stylesheet" href="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/css/bootstrap-theme.min.css">

  <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  <script src="http://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>

  <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
  <script src="http://cdn.bootcss.com/twitter-bootstrap/3.0.3/js/bootstrap.min.js"></script>
  <!-- 自己服务器上的markdown的js文件 -->
  <script src="http://47.94.165.122/MarkdownIME.js"></script>
  <script src="http://47.94.165.122/showdown.min.js"></script>
  <style media="screen">
    .shadow {
      position: fixed;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: #000;
      opacity: 0.3;
      filter: alpha(opacity=30);
    }

    .mod_dialog {
      position: fixed;
      left: 0%;
      top: 0%;
      width: 100%;
      height: 100%;
      background: #fff;
    }
  </style>
  <script>
    function compile() {
      var text = document.getElementById("content").value;
      var converter = new showdown.Converter();
      var html = converter.makeHtml(text);
      document.getElementById("result").innerHTML = html;
    }
    function compile1() {
      var text = document.getElementById("content1").value;
      var converter = new showdown.Converter();
      var html = converter.makeHtml(text);
      document.getElementById("result1").innerHTML = html;
    }
  </script>
</head>

<body>
  <div class="page">
    <ul class="nav nav-tabs">
      <li>
        <a href="/admin/">管理首页</a>
      </li>
      <li>
        <a href="/admin/banners">banner设置</a>
      </li>
      <li>
        <a href="/admin/images">images上传</a>
      </li>
      <li>
        <a href="/admin/news">公司新闻</a>
      </li>
      <li>
        <a href="/admin/contact">联系方式</a>
      </li>
      <li>
        <a href="/admin/msg">留言管理</a>
      </li>
      <li>
        <a href="/admin/companyInfor">公司简介</a>
      </li>
      <li>
        <a href="/admin/headDescription">公司公告</a>
      </li>
      <li>
        <a href="/admin/companyHistory">公司历程</a>
      </li>
      <li>
        <a href="/admin/industryconsulting">行业咨询</a>
      </li>
      <li>
        <a href="/admin/partners">合作伙伴</a>
      </li>
      <li class="active">
        <a href="/admin/product">产品服务</a>
      </li>
      <li>
        <a href="/admin/map">自定义地图</a>
      </li>
      <li>
        <a href="/admin/navname">一级导航名</a>
      </li>
    </ul>
    <div class="content-wrap">
      <div>
        <form action="?" method="post" enctype="multipart/form-data" role="form">
          <label for="product_name"> 产品名称：</label>
          <input type="text" name="product_name" id="product_name" class="form-control" placeholder="请输入标题" />
          <label for="product_description"> 产品描述：</label>
          <textarea name="product_description" id="product_description" class="form-control" rows="5" placeholder="输入副标题"></textarea>
          <label for="f1"> 产品封面：</label>
          <input type="file" name="url" id="f1" placeholder="选择文件" />
          <label for="content"> 产品详细内容：</label>
          <textarea id="content" name="content" class="form-control" rows="10" onkeyup="compile()"></textarea>
          <div id="result"></div>
          <label for="post_time">编辑时间：</label>
          <input type="date" name="post_time" id="post_time">
          <label for="product_type"> 类型：</label>
          <input type="text" name="product_type" id="product_type" class="form-contrl" />
          <br>
          <button type="submit" class="btn btn-default">添加</button>
        </form>
      </div>
      <table class="table table-striped table-bordered table-hover container-fluid" style="table-layout:fixed">
        <thead class="row">
          <tr>
            <th class="col-md-1">ID</th>
            <th class="col-md-1">产品名称</th>
            <th class="col-md-2">产品描述</th>
            <th class="col-md-1">图片</th>
            <th class="col-md-5">产品详细内容</th>
            <th class="col-md-1">类型</th>
            <th class="col-md-1">操作</th>
          </tr>
        </thead>
        <tbody class="row">
          <% for(var i=0;i<productdata.length;i++){ %>
            <tr>
              <td>
                <%=productdata[i].ID%>
              </td>
              <td>
                <%=productdata[i].product_name%>
              </td>
              <td>
                <%=productdata[i].product_description%>
              </td>
              <td>
                <img width="160px" src="/upload/<%=productdata[i].image_url%>" />
              </td>
              <td style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;">
                <%=productdata[i].content%>
              </td>

              <td>
                <%=productdata[i].product_type%>
              </td>
              <td>
                <a class="btn btn-warning" href="?act=mod&id=<%=productdata[i].ID%>">修改</a>
                <a class="btn btn-danger" href="?act=del&id=<%=productdata[i].ID%>" onclick="return confirm('你真的要删吗？')">删除</a>
              </td>
            </tr>
            <% } %>
        </tbody>
      </table>
      <% if(typeof mod_data!='undefined'){ %>
        <div class="shadow"></div>
        <div class="mod_dialog">
          <form action="?" method="post" enctype="multipart/form-data">
            <input type="hidden" name="mod_id" value="<%= mod_data.ID %>" />
            <label for="product_namechange"> 产品名称：</label>
            <input type="text" id="product_namechange" name="product_name" class="form-control" value="<%= mod_data.product_name %>"
            />
            <label for="product_description1"> 产品描述：</label>
            <textarea name="product_description" id="product_description1" class="form-control" rows="5"><%= mod_data.product_description %></textarea>
            <label for="url"> 封面图片：</label>
            <input type="file" name="url" id="url" class="form-control" />
            <label for="content1"> 产品详细内容：</label>
            <textarea name="content" id="content1" class="form-control" rows="10" onkeyup="compile1()"><%= mod_data.content %></textarea>
            <div id="result1"></div>
            <br>
            <label for="post_time">编辑时间：</label>
            <input type="date" name="post_time" id="post_time" value="<%= mod_data.post_time %>">
            <label for="product_typechange"> 类型：</label>
            <input type="text" name="product_type" id="product_typechange" value="<%= mod_data.product_type %>" />
            <br>
            <input class="btn btn-danger" type="submit" value="修改" />
            <a class="btn btn-warning" href="/admin/product">取消修改</a>

          </form>
        </div>
        <% } %>
    </div>
  </div>
</body>

</html>